<template>
    <div id="step4">
        <div class="weui-cells__title">查询对象信息</div>
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__hd">姓名</div>
                <div class="weui-cell__bd">
                    <p>{{ this.$store.state.inputName }}</p>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">身份证号</div>
                <div class="weui-cell__bd">
                    <p>{{ this.$store.state.inputFrid }}</p>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">手机号</div>
                <div class="weui-cell__bd">
                    <p>{{ this.$store.state.inputPhone }}</p>
                </div>
            </div>
        </div>
        <div id="validate-result">
            <div v-show="this.rlsb != ''" class="weui-cells__title">活体人脸识别</div>
            <div  v-show="this.rlsb != ''" class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__hd">人脸比对</div>
                    <div class="weui-cell__bd"><p>{{ rlsb }}</p></div>
                </div>
            </div>

            <div v-show="this.blxx != ''" class="weui-cells__title">不良信息(刑事、民事)</div>
            <div v-show="this.blxx != ''" class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__hd">不良信息(刑事、民事)</div>
                    <div class="weui-cell__bd"><p>{{ blxx }}</p></div>
                </div>
            </div>

            <div v-show="this.sjyhkbd != ''" class="weui-cells__title">银行卡信息验证</div>
            <div v-show="this.sjyhkbd != ''" class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__hd">姓名、身份证、银行卡</div>
                    <div class="weui-cell__bd"><p>{{ sjyhkbd }}</p></div>
                </div>
            </div>

            <div v-show="this.fqzf != ''" class="weui-cells__title">社交反欺诈分计算</div>
            <div v-show="this.fqzf != ''" class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__hd">社交反欺诈分</div>
                    <div class="weui-cell__bd"><p>{{ fqzf }}</p></div>
                </div>
            </div>

            <div v-show="this.xyfpj != ''" class="weui-cells__title">信用分计算</div>
            <div v-show="this.xyfpj != ''" class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__hd">信用分</div>
                    <div class="weui-cell__bd"><p>{{ xyfpj }}</p></div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
// 判断是否为数组
function isArray(o) {
    return Object.prototype.toString.call(o) == '[object Array]';
}
export default  {
    name: 'Vresults',  // 组件名称
    data () {  // 数据
        return {
          xyfpj: '',  // 信用分
          fqzf:'',  // 反欺诈
          blxx:'',  // 不良信息
          rlsb:'',  // 优图视频人脸识别
          sjhmd:'',  // 手机黑名单
          sjyhkbd:'', // 手机银行卡比对
          jkyzsb:''  // 商务信用分
        }
    },
    beforeMount:function processingData() {
        console.log("beforeMounted.....");
        console.dir(this.$store.state.validata);
        for(var i=0,l=this.$store.state.validata.length;i<l;i++){
            var queryData = this.$store.state.validata[i];
            if (!queryData.interId || queryData.interId == null || queryData.interId == "null" || queryData.interId == "undefind") { // 验证失败
                this.jkyzsb = "验证失败";
            }
            if (queryData.funcId == "008") { // 商务信用分
                this.processingSWF(queryData);
            } else if (queryData.interId == "0002" && queryData.channelId == "tengxun") { // 反欺诈
                this.processingFQZ(queryData);
            } else if (queryData.interId == "M005" && queryData.channelId == "suanhua") { // 手机号实名制比对结果 pc上的
            } else if (queryData.interId == "0001" && queryData.channelId == "kexin") { // 不良信息黑黑名单
                this.processingBLXX(queryData);
            } else if (queryData.interId == "0001" && queryData.channelId == "tengxun") {// 优图视频人脸识别
                this.processingRLSB(queryData);
            } else if (queryData.interId == "8002" && queryData.channelId == "suanhua") { // 手机黑名单
                this.processingSJYZ(queryData);
            } else if (queryData.interId == "3012" && queryData.channelId == "suanhua") { // 手机信用查找3012
                this.processingSHJHXY(queryData);
            } else if (queryData.interId == "1003" && queryData.channelId == "suanhua") { // 手机银行卡比对
                this.processingSJXY(queryData);
            } else if (queryData.interId == "2001" && queryData.channelId == "suanhua") { // 算话多重身份

            } else if (queryData.interId == "8005" && queryData.channelId == "suanhua") { // 算话逾期信息

            } else if (queryData.interId == "8006" && queryData.channelId == "suanhua") { // 算话贷款信息

            } else if (queryData.interId == "5003" && queryData.channelId == "suanhua") { // 算话贷款信息

            } else {  // 验证失败
                this.jkyzsb = "验证失败";
            }
        }



    },
    methods:{ // 自定义方法，可对data进行处理
        initData(){
            this.xyfpj = '';  // 信用分
            this.fqzf ='';  // 反欺诈
            this.blxx ='';  // 不良信息
            this.rlsb ='';  // 优图视频人脸识别
            this.sjhmd ='';  // 手机黑名单
            this.sjyhkbd =''; // 手机银行卡比对
            this.jkyzsb ='';  // 商务信用分
        },
        processingSWF(queryData){  // 商务信用分
            var createTabelData;
            if (queryData.code == "0000") {
                if (queryData.verify && queryData.verify != "" && queryData.verify != "null" && queryData.verify != null && queryData.verify != "undefined") {
                    var verify=JSON.parse(queryData.verify);
                    var xypf = verify[verify.length-1][1];
                    var xypj = "";
                    for (var i = 0, l = scoreMap.length; i < l; i++) {
                        if (parseInt(xypf) >= parseInt(scoreMap[i].value1) && parseInt(xypf) < parseInt(scoreMap[i].value2)) {
                            xypj = scoreMap[i].valueName;
                        }
                    }
                    this.xyfpj = xypf+ " (" + xypj + ")";
                }
            } else {
                this.xyfpj = "计算失败";
            }
        },
        processingFQZ(queryData){// 反欺诈
            var createTabelData;
            if (queryData.code == "0000") {
                if (queryData.verify && queryData.verify != "" && queryData.verify != "null" && queryData.verify != null && queryData.verify != "undefined") {
                    this.fqzf = queryData.verify;
                }
            } else {
                this.fqzf = "验证失败";
            }
        },
        processingBLXX(queryData){
            // 不良信息黑黑名单
            if (queryData.code == "0000") {
                if (queryData.data != "" && queryData.data != null && queryData.data != "null" && queryData.data != "undefind") {
                    //    identifyMap[2].data[3].value = queryData.data;
                    this.blxx = "没有不良信息";
                } else {

                    this.blxx = "没有不良信息";
                }
            } else {
                this.blxx = "验证失败"
            }
        },
        processingRLSB(queryData){
            // 优图视频人脸识别
            // 人脸识别 值对应码
            var errorCodeMessage = {
                "-4006": "视频中自拍照特征提取失败",
                "-4007": "视频中自拍照之间对比失败",
                "-4009": "Card照片提取特征失败",
                "-4010": "自拍照与Card照片相似度计算失败",
                "-4015": "自拍照人脸检测失败",
                "-4016": "自拍照解码失败",
                "-4017": "Card照片人脸检测失败",
                "-5001": "Card照片解码失败",
                "-5002": "唇语失败",
                "-5005": "自拍照解析照片不足",
                "-5007": "视频没有声音",
                "-5008": "声音识别失败",
                "-5009": "视频人脸检测失败，没有嘴或者脸",
                "-5010": "唇动失败",
                "-5011": "活体检测失败--不是活体",
                "-5012": "视频中噪声太大",
                "-5013": "视频里的声音太小",
                "-5014": "活体检测level参数无效",
                "-5015": "视频像素太低，最小320*480",
                "-5016": "视频里的人不是活体（疑似翻拍视频等攻击）",
                "-5801": "请求缺少身份证号码或身份证姓名",
                "-5802": "服务器内部错误，服务暂时不可用，请稍后重试",
                "-5803": "身份证姓名与身份证号码不一致",
                "-5804": "身份证号码无效",
                "-5805": "用户未输入图像或者 url 下载失败",
                "-5806": "身份证号码或者身份证姓名格式错误",
                "-5807": "查询身份证信息失败",
                "-9999": "视频验证人与身份证本人相似度低于50%"
            };
            if(queryData.code == "0000"){
                if(queryData.verify  == "0"){
                    if (parseInt(queryData.verifyMsg) > 50 && parseInt(queryData.verifyMsg) < 101) {
                        vthis.rlsb = "验证通过(相似度" + queryData.verifyMsg + ")";
                    } else {
                        vthis.rlsbg = "非身份证本人(相似度" + queryData.verifyMsg + ")";
                    }
                }else{
                    vthis.rlsb = "人脸识别失败";
                    var codeArray = queryData.verifyMsg.split(",");
                    if(codeArray[0] != "0"){
                        vthis.rlsb = errorCodeMessage[codeArray[0]];
                    }else if(codeArray[1]){
                        vthis.rlsb = errorCodeMessage[qcodeArray[1]];
                    }
                }
            }else{
                vthis.rlsb = "人脸识别失败";
            }
            this.rlsb = queryData.verifyMsg;
            if (errorCodeMessage[queryData.verifyMsg]) {
                this.rlsb = errorCodeMessage[queryData.verifyMsg];
            } else if (parseInt(queryData.verifyMsg) > 50 && parseInt(queryData.verifyMsg) < 101) {
                this.rlsb = "验证通过(相似度" + queryData.verifyMsg + ")";
            } else {
                vthis.rlsb = "非身份证本人";
            }
        },
        processingSJYZ(queryData){// 手机黑名单
            var createTabelData;
            if (queryData.code == "0000") {
                if (queryData.verify == "1") {
                    if (queryData.data && queryData.data != "") {
                        this.sjhmd = "有手机号黑名单记录";
                        createTabelData = queryData.data;
                    } else {
                        his.sjhmd = "没有数据";
                    }
                } else {
                    his.sjhmd = "未查得";
                }
            } else {
                his.sjhmd = "验证失败";
            }
        },
        processingSJXY(queryData){// 手机银行卡比对
            if (queryData.code == "0000") {
                if (queryData.verify == "1") {
                    this.sjyhkbd = "比对一致";
                } else if (queryData.verify == "2") {
                    this.sjyhkbd = "比对不一致";
                } else if (queryData.verify == "31") {
                    this.sjyhkbd  = "请求参数错误";
                } else if (queryData.verify == "5") {
                    this.sjyhkbd = "银行卡不支持";
                } else {
                    this.sjyhkbd = "未查得";
                }
            } else {
                this.sjyhkbd = "比对失败";
            }

        },
        processingDCSF(queryData){// 算话多重身份
            var createTabelData;
            if (queryData.code == "0000") {
                if (queryData.verify == "1") {
                    //"查得";
                } else {
                    //"未查得";
                }
            } else {
                //"验证失败";
            }
        },
        processingSHJHXY(queryData){ // 手机信用查找3012
            var createTabelData;
             if (queryData.code == "0000") {
                if (queryData.verify == "1") {
                    if (queryData.data && queryData.data != "" && queryData.data != null && queryData.data != "undefind") {
                        createTabelData = queryData.data;
                    } else {
                        createTabelData = [{
                            "title": "手机号信用核查",
                            "value": "没有数据"
                        }];
                    }
                } else if (queryData.verify == "2") {
                    createTabelData = [{
                        "title": "手机号信用核查",
                        "value": "未查得"
                    }];
                } else if (queryData.verify == "31") {
                    createTabelData = [{
                        "title": "手机号信用核查",
                        "value": "请求参数错误"
                    }];
                } else if (queryData.verify == "5") {
                    createTabelData = [{
                        "title": "手机号信用核查",
                        "value": "请求参数错误"
                    }];
                } else {
                    createTabelData = [{
                        "title": "手机号信用核查",
                        "value": "未查得"
                    }];
                }
            } else {
                createTabelData = [{
                    "title": "手机号信用核查",
                    "value": "验证失败"
                }];
            }
        }
    }
}
</script>

<style lang='scss' scoped>
.weui-cell__hd {
    width: 110px;
}
#validate-result > .weui-cells__title {
    margin-top: 10px;
    margin-bottom: 0px;
    padding-bottom: 0.3em;
    padding-top: 0.3em;
    background-color: #fff;
}
</style>
